using System;
using L=Science.Physics.GeneralPhysics;
using M = Science.Mathematics.Calculus;

namespace Serway.Chapter05
{
	/// <summary>
	/// Example04: A traffic light at rest
	/// A traffic light weighing 122 N hangs from a cable tied
	/// to two other cables fastened to a support, as in Figure
	/// 5.10a. The upper cables make angles of 37^{\circle} and 53^{\circle} 
	/// with the horizontal. These upper cables are not as
	/// strong as the vertical cable, and will break if the tension
	/// in them exceeds 100 N. Will the traffic light remain hanging
	/// in this situation, or will one of the cables break?
	/// T_1 = 73.4 N, T_2 = 97.4 N.
	/// </summary>
	public class Example04
	{
		public Example04()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			// T1 cos37 - T2 cos53 = 0;
			// T1 sin37 + T2 sin53 = T3;
			M.LinearEquation eq = new M.LinearEquation();
            double[,] mat = { {Math.Cos(37.0*Math.PI/180.0),-Math.Cos(53.0*Math.PI/180.0) }, 
                {Math.Sin(37.0*Math.PI/180.0),Math.Sin(53.0*Math.PI/180.0) } };
            double[] vec = {0.0,122.0};
            eq.Matrix = mat;
            eq.Vector = vec;
			eq.Solve();
			result += Convert.ToString(eq.Solution[0])
				+"     "+Convert.ToString(eq.Solution[1]);
		}
	}
}
